#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
struct P{
   LL h,w,id;
}a[maxn*2];
LL tot=0;
vector<LL>v[maxn];
bool cmp(P A,P B){
    if(A.h==B.h) return A.w>B.w;
    return A.h<B.h;
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n;cin>>n;
    tot=0;
    for(LL i=0;i<n*2+10;i++) v[i].clear();
    for(LL i=1;i<=n;i++){
        LL h,w;cin>>h>>w;
        a[++tot].h=h;a[tot].w=w;a[tot].id=i;
        a[++tot].h=w;a[tot].w=h;a[tot].id=i;
    }
    sort(a+1,a+1+tot,cmp);
    v[a[1].id].push_back({-1});

    LL pos=a[1].id;
    LL minw=a[1].w;
    LL minh=a[1].h;

    for(LL i=2;i<=tot;i++){
        if(a[i].h>minh&&a[i].w>minw){
            v[a[i].id].push_back({pos});
        }
        if(minw>a[i].w){
            minw=a[i].w;
            minh=a[i].h;
            pos=a[i].id;
        }
    }
    for(LL i=1;i<=n;i++){
        if(v[i].size()==0) cout<<"-1"<<" ";
        else cout<<v[i][0]<<" ";
    }
    cout<<"\n";
  }
return 0;
}
